#include <iostream>
using namespace std;
#include <string>
#include <unistd.h>

namespace zq
{
    template <class T>
    struct __list_node
    {
    public:
        __list_node(const T &val = T()) : _prev(nullptr), _next(nullptr), _data(val)
        {
        }

    private:
        __list_node<T> *_prev;
        __list_node<T> *_next;
        T _data;
    };



    template<class T>
    struct __list_iterator{
        typedef __list_node<T> Node;
        Node* _node;//迭代器的本质


        __list_iterator(Node* node):_node(node){

        }

        T& operator*(){
            return _node->_data;

        }
        T* operator->(){
            return &_node->_data;
        }

        __list_iterator<T> operator++(){
            __list_iterator<T> tmp(this->_node);
            this->_node= _node->_next;
            return tmp;
        }


        
    };

    template <class T>
    class list
    {
        typedef __list_node<T> Node;

    public:
        list()
        {
            _head = new Node;
            _head->_next = _head;
            _head->_prev = _head;
        }
        void push_back(const T& x){
            Node* tail = _head->_prev;
            Node* newnode = new Node(x);


            tail->_next = newnode;
            newnode->_next =_head;
            newnode->_prev = tail;
            _head->_next = newnode;
        }



        ~list()
        {
            delete _head;
            _head = nullptr;
        }

    private:
        Node *_head;
    };

}